<template>
	<view class="swiper-container">
		<swiper :autoplay="true" :circular="true" :interval="3000" :duration="500" :current="swiperCur"
			:indicator-dots="true" @change="swiperChange">
			<block v-for="(item, index) in data" :key="index">
				<swiper-item :class="{ active: index == swiperCur }">
					<view @click="goDetail(item._id)" class="slide-navigator acea-row row-between-wrapper">
						<image :src="item.img" mode="aspectFill" class="img" ></image>
					</view>
				</swiper-item>
			</block>
		</swiper>
	</view>
</template>

<script>
	export default {
		name: "MyAdvertise",
		data() {
			return {
				swiperCur: 0,
			};
		},
		props: {
			data: {
				type: Array,
				default: () => []
			}
		},
		methods: {
			swiperChange(e) {
				let {
					current,
					source
				} = e.detail;
				if (source === "autoplay" || source === "touch") {
					this.swiperCur = e.detail.current;
				}
			},
			goDetail(id) {
				uni.navigateTo({
					url:"/pages/watchMovie/videos?id=" + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.swiper-container{
		width: 100%;
		.swiper-item{
			border-radius: 15rpx;
		}
		.acea-row{
			border-radius: 15rpx;
			height: 100%;
		}
		.img{
			width: 100%;
			height: 100%;
			border-radius: 15rpx;
		}
	}

</style>